package com.yuexun.dhdoctor.module.mythings.presenter.impl;


import com.yuexun.dhdoctor.module.mythings.bean.TaskData;
import com.yuexun.dhdoctor.module.mythings.model.IThingsMySelfModel;
import com.yuexun.dhdoctor.module.mythings.presenter.IThingsMySelfPresenter;
import com.yuexun.dhdoctor.module.mythings.ui.view.IThingsMySelfView;

import org.kymjs.kjframe.ui.ViewInject;

import java.util.Map;

import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by work-jx on 2016/7/27.
 */
public class ThingsMySelfPresenter implements IThingsMySelfPresenter {
    private IThingsMySelfView view;
    private IThingsMySelfModel model;

    //记录Log
//    private final Logger log = ProUtil.getLogger(LoginPresneter.class);

    public ThingsMySelfPresenter(IThingsMySelfModel model, IThingsMySelfView view) {
        this.model = model;
        this.view = view;
    }
    
    @Override
    public void getTaskDatas(Map<String, String> praise) {
        model.getTaskDatas(praise)
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new Subscriber<TaskData>() {

                    @Override
                    public void onCompleted() {
                        
                    }

                    @Override
                    public void onError(Throwable e) {
                        ViewInject.toast("请检查网络状态");
                    }

                    @Override
                    public void onNext(TaskData taskData) {
                        view.showTaskDatas(taskData);
                    }
                });
    }


}
